package chess;

/**
 *  Bishop piece class
 * @author Dave
 * @param Int a value to represent the player who owns it
 */
public class Bishop extends Piece
{
    
    public Bishop(int color)
    {
        pieceColor = color;
    }//end of constructor
    
    public int canMove(int sourceX, int sourceY, int destX, int destY)
    {
        // Return false if coordinates are outside of the board.
        if(sourceX < 0 || sourceX > 7 || sourceY < 0 || sourceY > 7 ||
                destX < 0 || destX > 7 || destY < 0 || destY > 7)
            return 0;
        // intializing variables
        int distanceX;
        int distanceY;
        int magnitude;
        
        //Calculating distance
        distanceX= destX- sourceX;
        distanceY= destY- sourceY;
        
        if (distanceY==0)// to make sure you can't divid by Zero
            return 0;//invalid
        
        else
            magnitude= Math.abs(distanceX) / Math.abs(distanceY);
        /* so if the absolute values of the distance between the destination x
        and current x are equal to the absolute value of the distance between
        destination y and current y. Then that means the piece is moving 
        diagonally. You can find out by dividing the two to see if they are the
        same
        */
        
        if (magnitude ==1)
            return 1;
        else
            return 0;
   
       
    }//end of canMove
    
    public char getType()
    {
        return 'B';
    }//end of getType
    
    public static int getValue()
    {
        return 3;
    }//end of getValue
    
    
}//end of Bishop
